package com.alan.server.entity;

import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableLogic;
import com.baomidou.mybatisplus.annotations.Version;
import lombok.Data;
import lombok.ToString;

import java.io.Serializable;
import java.util.Date;

/**
 * Created by Alan on 17-10-11
 */
@Data
@ToString
public abstract class BaseModel<T extends Model> extends Model<T> {
    public static final String ID = "id";
    public static final String EXTRA_INFO = "extra_info";
    public static final String DEL_FLAG = "del_flag";
    public static final String CREATE_BY = "create_by";
    public static final String CREATE_DATE = "create_date";
    public static final String UPDATE_BY = "update_by";
    public static final String UPDATE_DATE = "update_date";
    public static final String REMARKS = "remarks";
    public static final String VERSION = "version";


    /**
     * 主键ID
     */
    @TableId("id")
    protected Long id;

    /**
     * 扩展字段
     */
    @TableField("extra_info")
    protected String extraInfo;

    /**
     * 删除标识位 0 1
     */
    @TableField(value = "del_flag")
    @TableLogic
    protected String delFlag;

    /**
     * 更新者
     */
    @TableField(value = "update_by")
    protected String updateBy;

    /**
     * 更新时间
     */
    // 注意！这里需要标记为填充字段
//    @TableField(fill = FieldFill.INSERT_UPDATE,value = "update_date")
    @TableField(value = "update_date")
    protected Date  updateDate;

    /**
     * 创建者
     */
    @TableField(value = "create_by")
    protected String createBy;

    /**
     * 创建时间
     */
    // 注意！这里需要标记为填充字段
//    @TableField(fill = FieldFill.INSERT,value = "create_date")
    @TableField(value = "create_date")
    protected Date  createDate;

    /**
     * 版本号（乐观锁）
     */
    @Version
    protected Integer version;

    @Override
    protected Serializable pkVal() {
        return this.id;
    }

}
